package com.example.androidcomplete02.fragment;

import android.app.Activity;
import android.app.DialogFragment;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.example.androidcomplete02.R;

public class DlgQuestFrg extends Activity implements
		QuestionDialogFragment.NoticeDialogListener {
	TextView tv;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch20_dialogex);
		tv = (TextView) findViewById(R.id.dialog_tv);
	}

	public void mOnClick(View v) {
		DialogFragment newFragment = new QuestionDialogFragment();
		Bundle bundle = new Bundle();
		bundle.putString("title", "질문");
		bundle.putString("msg", "어떤 연산을 하시겠습니까?");
		bundle.putString("Q1", "덧셈");
		bundle.putString("Q2", "곱셈");
		bundle.putInt("a", 3);
		bundle.putInt("b", 4);
		newFragment.setArguments(bundle);
		newFragment.show(getFragmentManager(), "Dialog");
	}

	public void onDialogClick(DialogFragment dialog, int res) {
		tv.setText("연산 결과 = " + res);
		Toast.makeText(this, "연산을 완료하였습니다", Toast.LENGTH_LONG).show();
	}
}